#version 460
#extension GL_GOOGLE_include_directive : enable

layout(points) in;
layout(line_strip, max_vertices=8) out;
//layout(points, max_vertices=64) out;

#include "../../../../core/shader_color.h"
#include "../../../../core/shader_tranform.h"
#include "../../../../core/shader_widget_color.h"
#include "../../../../core/shader_widget_mesh.h"



layout(location = 1) in VS_GS_VERTEX {
	uint vInstance;
}vertex_in[];


layout(location = 0) out vec4 gColor;
out gl_PerVertex {
	vec4	gl_Position;
};



//vec4 v = vec4(0, 0, 0, 1);

void main(void){
	uint Instance = vertex_in[0].vInstance;
	vec2 gap = m_meshHV_gap[Instance];
	vec4 Color = f_glsl_buildColor(InstanceColor[Instance]);
    Color = vec4(0,0,0,1);
    uint width  = vertNum>>16;
    uint heigth = vertNum&0xffff;


    vec4 vert = vec4(0, gap.y, 0, 1);
    vert.xy *= m_Scale;
    vert.xy += m_Loc;
    vert.xy = round(vert.xy + vec2(0.5));
    gl_Position = mat_ProjecView * vert;
    gColor = Color;
    EmitVertex();

    vert = vec4(width, gap.y, 0, 1);
    vert.xy *= m_Scale;
    vert.xy += m_Loc;
    vert.xy = round(vert.xy + vec2(0.5));
    gl_Position = mat_ProjecView * vert;
    gColor = Color;
    EmitVertex();
    EndPrimitive();



    vert = vec4(gap.x, 0, 0, 1);
    vert.xy *= m_Scale;
    vert.xy += m_Loc;
    vert.xy = round(vert.xy + vec2(0.5));
    gl_Position = mat_ProjecView * vert;
    gColor = Color;
    EmitVertex();

    vert = vec4(gap.x, heigth, 0, 1);
    vert.xy *= m_Scale;
    vert.xy += m_Loc;
    vert.xy = round(vert.xy + vec2(0.5));
    gl_Position = mat_ProjecView * vert;
    gColor = Color;
    EmitVertex();
	EndPrimitive();
	
}



 